/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package m;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mikael Köhlmyr | mikael@kohlmyr.com | http://www.kmyr.net
 */
public class io {

    public static File getFile(String filename){
        File file = new File(filename);
        if(file.exists() || file.isFile() || file.canRead()){
            file = new File(filename);
        }
        else{
            file = null;
        }
        return file;
    }

    public static BufferedReader getFileReader(File file){
        BufferedReader br = null;
        try{
            br = new BufferedReader(new FileReader(file));
        }
        catch(FileNotFoundException ex){
            Logger.getLogger(io.class.getName()).log(Level.SEVERE, null, ex);
        }
        return br;
    }

    public static PrintWriter getFileWriter(File file){
        PrintWriter pw = null;
        try{
            pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
        }
        catch(IOException ex){
            Logger.getLogger(io.class.getName()).log(Level.SEVERE, null, ex);
        }
        return pw;
    }

    public static void echo(String out){
        System.out.println(out);
    }

    public static void echo(int out){
        System.out.println(out);
    }

    public static void echo(boolean out){
        Boolean strout = out;
        System.out.println(strout.toString());
    }
}